package mspdt.pocket.wallet;

import java.lang.reflect.Array;
import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;

public class MainInformation extends Activity{
	
	
	ListView main_list;
	DBAdapter db;
	Button settings, add_account, help;
	AccountAdapter account_adapter;
	ArrayList<Integer> account_ids = new ArrayList<Integer>();
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_information);
		settings = (Button)findViewById(R.id.main_screen_settings);
		add_account = (Button)findViewById(R.id.main_screen_add_account);
		help = (Button)findViewById(R.id.main_screen_help);
		main_list = (ListView)findViewById(R.id.main_screen_account_list);
		db = new DBAdapter(this);
		db.openDataBase();
		account_adapter = new AccountAdapter(this, db.getAccounts(), db.getAmounts());
		account_ids = db.getAccountIds();
		db.close();
		main_list.setAdapter(account_adapter);
		main_list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				Bundle bundle = new Bundle();
				
				Intent account_information = new Intent(getApplicationContext(), AccountInformation.class);
				
				bundle.putInt("account_id", account_ids.get(arg2));
				
				account_information.putExtras(bundle);
				startActivity(account_information);
			}
		});
	}

}
